/*
    Copyright 2010 Justin Lipton, Jonathan Rosenberg
    
    This file is part of MediaList.

    MediaList is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    MediaList is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MediaList.  If not, see <http://www.gnu.org/licenses/>.
*/

var xmlhttp;

function GetXmlHttpObject()
{
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

function changeToEdit(currentUser)
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    var url = "editAboutMe.php";
    url=url+"?currentUser="+currentUser;
    xmlhttp.onreadystatechange=changeAbout;
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}

function editAbout(A,B)
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }
    
    //if(A.length > 3000)
    //{
    //    document.getElementById("aboutmeerror").innerHTML="text longer than 3000<br />";
    //    return;
    //}
    
    var url = "aboutMe.php";
    var data = "data=" + A;
    xmlhttp.onreadystatechange=changeAbout;
    xmlhttp.open("POST", url, true);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    //xmlhttp.open("GET", url, true);
    xmlhttp.send(data);
}

function changeAbout()
{
  if (xmlhttp.readyState==4)
  {
    document.getElementById("aboutme").innerHTML=xmlhttp.responseText;
  }
}